package org.example.mybatis.service;

import org.example.mybatis.mapper.UserInfoMapper;
import org.example.mybatis.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserInfoMapper userInfoMapper ;
    public  UserInfo queryUserInfoByUserNameAndPassword(String username, String password) {
        if(!StringUtils.hasLength(username) || ! StringUtils.hasLength(password)){
            return null ;
        }
        // 查数据库 ,查到就 返回
        List<UserInfo> userInfos = userInfoMapper.queryUserInfoByUserNameAndPassword(username , password);
        if(userInfos.size() >0){
            return userInfos.get(0);
        }
        return null ;
    }

    public List<UserInfo> queryUserInfoList(){
        return userInfoMapper.queryUserInfoList();
    }
}
